package org.arch_learn.servlet_container.auto_config;


import org.arch_learn.flashboot.autoconfigure.Bean;
import org.arch_learn.flashboot.autoconfigure.Configuration;
import org.arch_learn.flashboot.autoconfigure.EnableConfigurationProperties;
import org.arch_learn.servlet_container.JerryRat;

@Configuration
@EnableConfigurationProperties(ServerProperties.class)
public class JerryRatServerAutoConfiguration {

    @Bean(value = "webServer")
    public JerryRat jerryRat(ServerProperties serverProperties) {
        return new JerryRat().addService(serverProperties.getPort(),
                        serverProperties.getBlockingQueueCapacity(),
                        serverProperties.getCorePoolSize(),
                        serverProperties.getMaximumPoolSize(),
                        serverProperties.getKeepAliveTime())
                .addEngine()
                .addHost(serverProperties.getHost())
                .addContext(serverProperties.getContextPath());
    }
}
